import http from '@/utils/http'
import {postApi, getApi, deleteApi, putApi} from './allApi' 
let api = {}
const doApi = (postApi, type) => {
    Object.keys(postApi).forEach((itemFirst)=>{
        if (!api[itemFirst]) {
            api[itemFirst] = {}
        }
        Object.keys(postApi[itemFirst]).forEach((item)=>{
            let configApi = postApi[itemFirst][item];
            api[itemFirst][item] = (function (configApi) {
                return function () {
                    let action = configApi;
                    return http[type](action, arguments[0]);
                }
            })(configApi);
        })
    })
}
doApi(postApi, 'post')
doApi(getApi, 'get')
doApi(deleteApi, 'deletes')
doApi(putApi, 'put')
export default api